package br.edu.ufcg.msnlab2.grupo09;

import static org.junit.Assert.*;

import java.math.BigDecimal;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import br.edu.ufcg.msnlab2.grupo09.ode.rungeKutta.RungeKutta;
import br.edu.ufcg.msnlab2.misc.Function;
import br.edu.ufcg.msnlab2.misc.FunctionImpl;

public class RungeKuttaTest {

	Function equation;
	RungeKutta solve;
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		equation = new FunctionImpl("30-6*y");
		solve = new RungeKutta(equation);
	
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public final void testRungekutta() {
		//fail("Not yet implemented"); // TODO
		BigDecimal testBigY = new BigDecimal(4.99999999999960476060323344427160918712615966796875);
		try {
			double testY = solve.rungekutta(0, 5, 1, 50);
			BigDecimal big = new BigDecimal(testY);
			assertTrue(big.equals(testBigY));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			fail(e.getMessage());
		}
		
		
	}

}
